package com.ruoyi.project.roadnet.baseBridge.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.project.roadnet.baseBridge.domain.BaseBridge;
import com.ruoyi.project.roadnet.baseBridge.service.IBaseBridgeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 桥梁信息操作处理
 * 
 * @author zhangdachen
 * @date 2019-04-16
 */
@Controller
@RequestMapping("/roadnet/baseBridge")
public class BaseBridgeController extends BaseController
{
    private String prefix = "roadnet/baseBridge";
	
	@Autowired
	private IBaseBridgeService baseBridgeService;
	
	@RequiresPermissions("roadnet:baseBridge:view")
	@GetMapping()
	public String baseBridge()
	{
	    return prefix + "/baseBridge";
	}
	
	/**
	 * 查询桥梁列表
	 */
	@RequiresPermissions("roadnet:baseBridge:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(BaseBridge baseBridge)
	{
		startPage();
        List<BaseBridge> list = baseBridgeService.selectBaseBridgeList(baseBridge);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出桥梁列表
	 */
	@RequiresPermissions("roadnet:baseBridge:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BaseBridge baseBridge)
    {
    	List<BaseBridge> list = baseBridgeService.selectBaseBridgeList(baseBridge);
        ExcelUtil<BaseBridge> util = new ExcelUtil<BaseBridge>(BaseBridge.class);
        return util.exportExcel(list, "baseBridge");
    }
	/**
	 * 查看桥梁
	 */
	@GetMapping("/view/{id}")
	public String view(@PathVariable("id") Integer id, ModelMap mmap)
	{
		BaseBridge baseBridge = baseBridgeService.selectBaseBridgeById(id);
		mmap.put("baseBridge", baseBridge);
	    return prefix + "/view";
	}
	/**
	 * 桥梁地图视图
	 */
	@GetMapping("/brigemap/{id}")
	public String map(@PathVariable("id") Integer id, ModelMap mmap)
	{
		BaseBridge bridge=baseBridgeService.selectBaseBridgeById(id);
		mmap.put("bridge", bridge);
		return prefix + "/map";
	}
}
